public class Operator {
    public static void main(String[] args) {
        int a = 20;
        int b = 10;

//        System.out.println(a + b);
//        System.out.println(a - b);
//        System.out.println(a * b);
//        System.out.println(a / b);
//        System.out.println(a % b);
//
        int a1 = 3;
        int b1 = 2;
        System.out.println(a1 / b1);

        double d = a1 * 1.0/b1;
        System.out.println(d);

        //
        int a2 = 1;
        int b2 = 0;
//        System.out.println(a2/b2);
        //%不仅可以对整型取模，也可以对double取模
        System.out.println(11.5 % 2.0);

        //
        System.out.println(1 + 0.2);

        int a3 = 1;
        a3 += 2;
        System.out.println(a3);

        a3 -= 1;
        System.out.println(a3);

        a3 *= 3;
        System.out.println(a3);

        a3 /= 3;
        System.out.println(a3);

        a3 %= 3;
        System.out.println(a3);

        //三.自增/自减运算符++--
        //++是变量+1，--是变量-1；

        int a4 = 1;
        a4++;
        System.out.println(a4++);
        System.out.println(a4);

        ++a4;
        System.out.println(++a4);
        System.out.println(a4);


        //关系运算符；
        int a5 = 10;
        int b5 = 20;
        //
        System.out.println(a5==b5);
        System.out.println(a5!=b5);
        System.out.println(a5 <b5);
        System.out.println(a5 >b5);
        System.out.println(a5<=b5);
        System.out.println(a5>=b5);
        System.out.println("========");

        int a6 = 1;
        int b6 = 2;
        //且&&；

        System.out.println(a6==1 && b6==2);
        System.out.println(a6==1 && b6>100);
        System.out.println(a6>100 && b6==2);
        System.out.println(a6>100 && b6>100);
        System.out.println("++++++++++++++");
        //逻辑||
        int a7 = 1;
        int b7 = 2;

        System.out.println(a7==1 || b7==2);
        System.out.println(a7==1 || b7>100);
        System.out.println(a7>100 ||b7==2);
        System.out.println(a7>100 || b7>100);
        System.out.println("----------------");
        //逻辑非！
        //语法：真变假，假变真。
        int a8 = 1;
        System.out.println(!(a8==1));
        System.out.println(!(a8!=1));
        System.out.println("))))))))))");
        //四.短路求值的规则
        System.out.println(10>20 && 10/0==0);
        System.out.println(10<20 || 10/0==0);
        System.out.println("____________");
        //五.位运算
        //1.按位与 &  :如果两个二进制位都是 1, 则结果为 1, 否则结果为 0.
        int a9 = 10;
        int b9 = 20;
        System.out.println(a9 & b9);
        //2.按位或 |：如果两个二进制位都是 0, 则结果为 0, 否则结果为 1
        int a10 = 10;
        int b10 = 20;
        System.out.println(a10 | b10);//结果为30；

        //3.按位取反: 如果该位为 0 则转为 1, 如果该位为 1 则转为 0
        int a11 = 0xf;
        System.out.printf("%x\n", ~a11);
        //4.按位取或^:如果两个数字的二进制位相同, 则结果为 0, 相异则结果为 1.
        System.out.println("按位取或：");
        int a12 = 0x1;
        int b12 = 0x2;
        System.out.printf("%x\n", a12^b12);







    }


}
